package com.ymatou.iapi.csim.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.csim.parameter.RemoveDiscourseCategoryByCategoryIdBean;
import com.ymatou.iapi.csim.parameter.SaveOrUpdateDiscourseCategoryBean;
import com.ymatou.iapi.csim.service.RemoveDiscourseCategoryByCategoryIdCall;
import com.ymatou.iapi.csim.service.SaveOrUpdateDiscourseCategoryCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CsimCallService;
import com.ymttest.database.model.ymt_discoursecategory;
import com.ymttest.database.sqlwapper.CSIM.ymt_discoursecategoryWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
/**
*删除话术分类
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_RemoveDiscourseCategoryByCategoryId{
	private static RemoveDiscourseCategoryByCategoryIdBean bean;
	private static RemoveDiscourseCategoryByCategoryIdCall call;
	private Integer csId=Integer.parseInt(EnvSetup.getData("csId").toString());
	private ymt_discoursecategoryWapper discoursecategoryWapper=new ymt_discoursecategoryWapper();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("删除话术分类");
	}

	@Before
	public void caseUp() {
		bean=new RemoveDiscourseCategoryByCategoryIdBean();
		call=new RemoveDiscourseCategoryByCategoryIdCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_RemoveDiscourseCategoryByCategoryId_1() {
		Logger.start(true,"删除话术分类");
		try {
			SaveOrUpdateDiscourseCategoryBean saveOrUpdateDiscourseCategoryBean=new SaveOrUpdateDiscourseCategoryBean();
			SaveOrUpdateDiscourseCategoryCall saveOrUpdateDiscourseCategoryCall=new SaveOrUpdateDiscourseCategoryCall();
			saveOrUpdateDiscourseCategoryBean.setCategoryId(TestDataManager.getRandomUUID().toString());
			saveOrUpdateDiscourseCategoryBean.setTitle("自动化测试_"+TestDataManager.getRandomNum(5));
			saveOrUpdateDiscourseCategoryBean.setCsId(csId);
			saveOrUpdateDiscourseCategoryBean.setSort(1);
			saveOrUpdateDiscourseCategoryBean.setRoleType("MAIJIA_KEFU");
			saveOrUpdateDiscourseCategoryCall.setData(saveOrUpdateDiscourseCategoryBean);
			saveOrUpdateDiscourseCategoryCall.callService();	
			
			bean.setCategoryId(saveOrUpdateDiscourseCategoryBean.getCategoryId());
			call.setData(bean);
			call.callService();		
			//验证
			Logger.verifyEquals("0", call.getResult().get("ErrorCode").toString(), "验证errorCode");
			Logger.verifyEquals(true, call.getResult().get("Success"), "验证Success");
			Logger.verifyEquals("200", call.getStatus(), "验证Status");
			ymt_discoursecategory category=discoursecategoryWapper.selectByPrimaryKey(saveOrUpdateDiscourseCategoryBean.getCategoryId());
			Logger.verifyEquals(-1, category.getAction(), "验证Action=-1:删除成功");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}